<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Captures a window</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.imagegrabwindow" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagegrabwindow</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.2, PHP 7)</p><p class="refpurpose"><span class="refname">imagegrabwindow</span> &mdash; <span class="dc-title">Captures a window</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.imagegrabwindow-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagegrabwindow</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$window_handle</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$client_area</code><span class="initializer"> = 0</span></span>
  ] ) : <span class="type">resource</span></div>

  <p class="para rdfs-comment">
   Grabs a window or its client area using a windows handle (HWND property in COM instance)
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    This function is only available on Windows.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.imagegrabwindow-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">window_handle</code></dt>

     <dd>

      <p class="para">
       The HWND window ID.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">client_area</code></dt>

     <dd>

      <p class="para">
       Include the client area of the application window.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imagegrabwindow-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an image resource identifier on success, <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.imagegrabwindow-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   E_NOTICE is issued if <code class="parameter">window_handle</code> is invalid
   window handle.
   E_WARNING is issued if the Windows API is too old.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.imagegrabwindow-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3715">
    <p><strong>Example #1 <span class="function"><strong>imagegrabwindow()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     Capture a window (IE for example)
    </p></div>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$browser&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">COM</span><span style="color: #007700">(</span><span style="color: #DD0000">"InternetExplorer.Application"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$handle&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$browser</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">HWND</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$browser</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Visible&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagegrabwindow</span><span style="color: #007700">(</span><span style="color: #0000BB">$handle</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$browser</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Quit</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"iesnap.png"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>
     Capture a window (IE for example) but with its content
    </p></div>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$browser&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">COM</span><span style="color: #007700">(</span><span style="color: #DD0000">"InternetExplorer.Application"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$handle&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$browser</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">HWND</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$browser</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Visible&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$browser</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Navigate</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://www.libgd.org"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Still&nbsp;working?&nbsp;*/<br /></span><span style="color: #007700">while&nbsp;(</span><span style="color: #0000BB">$browser</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Busy</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">com_message_pump</span><span style="color: #007700">(</span><span style="color: #0000BB">4000</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagegrabwindow</span><span style="color: #007700">(</span><span style="color: #0000BB">$handle</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$browser</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Quit</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"iesnap.png"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.imagegrabwindow-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="imagegrabscreen.html" class="function" rel="rdfs-seeAlso">imagegrabscreen()</a> - Captures the whole screen</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>